home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 8 / Eagles_Nest_Mac_Collection_Disc_8.TOAST / Developer Tools⁄Additions / MacUserProj / MacUser Projects / June / 2GenApp Src / DialogUtil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-25  |  2.9 KB  |  102 lines  |  [TEXT/KAHL]

  1. /* *****************************************************************************
  2.     FILE:             DialogUtil.c
  3.     
  4.     DESCRIPTION:     Dialog box utilities
  5.     
  6.     AUTHOR:            Kurt W.G. Matthies
  7.         
  8.     Copyright © 1990 by Code of the West, Inc., All Rights Reserved.
  9.  
  10.     
  11.     Revision History:
  12.     ==========================================================
  13.     4.24.90 -     June 1990 MacUser Release: No Changes
  14.     3.30.90    -    May 1990 MacUser Release
  15.     ==========================================================
  16.  
  17.    ***************************************************************************** */
  18. #include "AppConstants.h"
  19.  
  20. #include "DialogUtilPr.h"
  21.  
  22. /* --------------------------------------------------------------------------
  23.     dialogHookProcs -    these hook procs do various things like
  24.     3.30.90kwgm            highlight buttons, draw underlines, or handle
  25.                         keydown events in dialog boxes.
  26. ----------------------------------------------------------------------------- */
  27. pascal void
  28. buttonProc (theDialog, theItem)        /* outline the default button of a dialog */
  29.     DialogPtr        theDialog;
  30.     short            theItem;
  31. {
  32.     short            type;
  33.     Rect            box;
  34.     Handle            itemHdl;
  35.  
  36.     GetDItem (theDialog, kSetButtonID, &type, &itemHdl, &box);
  37.     
  38.     PenSize (3, 3);
  39.     InsetRect (&box, -4, -4);
  40.     FrameRoundRect (&box, 16, 16);
  41.     PenNormal ();
  42.     
  43. } /* buttonProc */
  44.  
  45. /* ----------------------------------------------------------------------------------
  46.     DLOGfilterProc1 -        called from inside of ModalDialog
  47.     3.30.90kwgm                uses button 1 as default, button 2 as cancel
  48.                             processes Return, Enter and cmd .
  49. ------------------------------------------------------------------------------------- */
  50. pascal Boolean
  51. DLOGfilterProc1 (theDialog, theEvent, theItem)
  52.     DialogPtr        theDialog;
  53.     EventRecord        *theEvent;
  54.     short            *theItem;
  55. {
  56.     short            type;
  57.     Rect            box;
  58.     char            c;
  59.     long            endTicks;
  60.     Boolean            result;
  61.     Handle            item;
  62.     
  63.     c = (theEvent->message & charCodeMask);
  64.     
  65.     if (c == 13 || c == 3)        /* return or enter */
  66.     {
  67.         /* get the item data from the DialogMgr */
  68.         GetDItem (theDialog, kSetButtonID, &type, &item, &box);
  69.         if (type == (ctrlItem | btnCtrl))
  70.         {
  71.             HiliteControl (item, true);        /* flash the button push */
  72.             Delay (8, &endTicks);
  73.             HiliteControl (item, false);
  74.         }
  75.         *theItem = kSetButtonID;            /* simulate button push */
  76.         theEvent->what = mouseDown;
  77.         result = true;
  78.     }
  79.     else if (c == '.' && theEvent->modifiers & cmdKey)    /* cmd . */
  80.     {
  81.         GetDItem (theDialog, kCancelButtonID, &type, &item, &box);
  82.         if (type == (ctrlItem | btnCtrl))
  83.         {
  84.             HiliteControl (item, true);
  85.             Delay (8, &endTicks);
  86.             HiliteControl (item, false);
  87.         }
  88.         *theItem = kCancelButtonID;
  89.         theEvent->what = mouseDown;
  90.  
  91.         result = true;
  92.     }
  93.     else
  94.         result = false;        /* tell ModalDialog that we did nothing */
  95.             
  96.     return (result);
  97.     
  98. } /* DLOGfilterProc1 */
  99.  
  100. /* ===========================================  EOF  ========================================
  101.     Copyright © 1990 by Code of the West, Inc., All Rights Reserved.
  102. ============================================================================================ */